# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=spike-proxy
pkgver=148
pkgrel=11
pkgdesc='A Proxy for detecting vulnerabilities in web applications.'
arch=('any')
url='http://www.immunitysec.com/resources-freesoftware.shtml'
license=('GPL')
groups=('blackarch' 'blackarch-webapp')
depends=('python2' 'python2-pyopenssl' 'bash')
source=("http://www.immunitysec.com/downloads/SP$pkgver.tgz"
        'fix-encoding.patch')
sha512sums=('dd420dbd0287f1f238da1af53289f46acf98be64fdac0f481f27d24b8e0109ee406c6edfd3fa2af2fa90e247c200bffa3de5dc550c6720ff13b39d88ef9dce5a'
            'c668f4b888dfe1617787d1bdd86c364bf05d54f9fc16fa1fe83389dbcf4ecf39b0b171d2cedc5ce0ddca14df3a8c97b7eaf65c53a2d4129f698e89d923776522')

prepare(){
  cd spkproxy

  patch -Np1 -i "$srcdir/fix-encoding.patch"
}

package() {
  cd spkproxy

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"
  install -dm 755 "$pkgdir/usr/share/doc/$pkgname"

  mv *.txt "$pkgdir/usr/share/doc/$pkgname/"

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/bash
cd /usr/share/$pkgname
exec python2 ./spkproxy.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

